Namespace("sketch.ui.common");

(function(ui, fwk) {
    ui.CheckBox = klass(fwk.ImageElement, {
        __type__: "Checkbox",
        _callSuper: false,
        _constructor: function(){
            ui.CheckBox.SuperConstructor.call(this, ui.CheckBox.checkedImageUrl, 16, 16);

            var that = this;
            var checked = this.properties.createProperty("checked", "Checked", true)
                .editorTemplate("#editor-checkbox")
                .useInModel();

            this.properties.bind(checked.propertyName, function(data){
                if (data.newValue) {
                    that.image.src = ui.CheckBox.checkedImageUrl;
                }
                else {
                    that.image.src = ui.CheckBox.unCheckedImageUrl;
                }
            });
        }
    });

    ui.CheckBox.checkedImageUrl = "img/checkbox/checked.png";
    ui.CheckBox.unCheckedImageUrl = "img/checkbox/unchecked.png";
})(sketch.ui.common, sketch.framework);